package com.wenwei.sharebox.net;

import com.wenwei.sharebox.bean.ApiResultBean;
import com.wenwei.sharebox.bean.AppMsgBean;
import com.wenwei.sharebox.bean.AppointmentBean;
import com.wenwei.sharebox.bean.BannerBean;
import com.wenwei.sharebox.bean.BaseGoodsBean;
import com.wenwei.sharebox.bean.DeviceGoodsBean;
import com.wenwei.sharebox.bean.GoodCateBean;
import com.wenwei.sharebox.bean.GoodsDetailsBean;
import com.wenwei.sharebox.bean.GoodsInfoBean;
import com.wenwei.sharebox.bean.HomeHotGoodsBean;
import com.wenwei.sharebox.bean.MessageListBean;
import com.wenwei.sharebox.bean.OrderGoodsBean;
import com.wenwei.sharebox.bean.ProposalBean;
import com.wenwei.sharebox.bean.RechargeInterageBean;
import com.wenwei.sharebox.bean.RefundBean;
import com.wenwei.sharebox.bean.RegisterBean;
import com.wenwei.sharebox.bean.RentBean;
import com.wenwei.sharebox.bean.ShareGoodsBean;
import com.wenwei.sharebox.bean.SupplyGoodsBean;
import com.wenwei.sharebox.bean.UpdateUserInfoBean;
import com.wenwei.sharebox.bean.UserIdentityBean;
import com.wenwei.sharebox.bean.UserLoginBean;
import com.wenwei.sharebox.bean.UserShareBean;
import com.wenwei.sharebox.bean.WeChatPayConfigBean;

import java.util.ArrayList;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.PATCH;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by Bo on 2016/7/5.
 *
 * API请求接口
 *
 * 封装所有的请求API接口
 */
public interface ApiInterface {


    /********************* Home模块 ****************************/
    //banner
    @GET("home/banner")
    Observable<ApiResultBean<ArrayList<BannerBean>>> getBanner();
    //热销商品
    @GET("home/getSaleTop8")
    Observable<ApiResultBean<ArrayList<HomeHotGoodsBean>>> getSaleTop8();
    //搜索商品 0租用 1购买 -1全部 (废弃)
    @GET("home/searchShareShopsRents")
    Observable<BaseGoodsBean> getSearchGoods(@Query("type") int type,
                                             @Query("searchname") String searchKey,
                                             @Query("currentPage") int page,
                                             @Query("pageSize") int size);
    //共享物品  0租用 1购买 (废弃)
    @GET("home/shareShopRents")
    Observable<BaseGoodsBean> getShareGoods(@Query("currentPage") int page,
                                            @Query("pageSize") int pageSize,
                                            @Query("type") int type);

    //共享购物（0租用 1购买 -1全局搜索）
    @GET("home/shareShopRents")
    Observable<BaseGoodsBean> getShareShopRents(@Query("type") int type,
                                                @Query("searchname") String searchKey,
                                                @Query("currentPage") int page,
                                                @Query("pageSize") int pageSize);
    //商品详情
    @GET("home/getShopDetails")
    Observable<ApiResultBean<GoodsDetailsBean>> getGoodsDetails(@Query("shop_id") int goodsId);

    //商品分类
    @GET("home/getShopClass")
    Observable<ApiResultBean<ArrayList<GoodCateBean>>> getGoodsCate();
    //商品列表
    @GET("home/shopList")
    Observable<BaseGoodsBean> getGoodsList(@Query("shopClassId") int id,
                                           @Query("currentPage") int page,
                                           @Query("pageSize") int size);
    /********************* 我的分享模块 ****************************/
    //我的购买(废弃)
    @GET("myshare/buy")
    Observable<UserShareBean> getUserShareBuy(@Query("currentPage") int page,
                                              @Query("pageSize") int pageSize);
    //我的租用(废弃)
    @GET("myshare/rent")
    Observable<UserShareBean> getUserShareRent(@Query("currentPage") int page,
                                              @Query("pageSize") int pageSize);

    //我的购买与租用（最新） type: 0 购买  1 租用
    @GET("share/buyAndRent")
    Observable<UserShareBean> getBuyAndRent(@Query("currentPage") int page,
                                               @Query("pageSize") int pageSize,
                                            @Query("type") int type);

    //申请退款
    @GET("share/refund")
    Observable<ApiResultBean<RefundBean>> refund(@Query("orderId") int id,
                                                 @Query("device_unique_num") String num,
                                                 @Query("refundReasons") String res);

    @GET("share/refundRent")
    Observable<ApiResultBean<RentBean>> rent(@Query("orderId") int orderId,
                                             @Query("device_unique_num") String num);
    /********************* Auth模块 ****************************/
    //登录
    @FormUrlEncoded
    @POST("auth")
    Observable<ApiResultBean<UserLoginBean>> userLogin(@Field("username")String phone,
                                                       @Field("password")String code,
                                                       @Field("registrationId")String pw,
                                                       @Field("platform") String timeSpan);
//    //刷新Auth
//    @GET("refresh")
//    Observable<ApiResultBean> setRegistrationId(@Body RequestBody body);
    //注册
    @FormUrlEncoded
    @POST("auth/register")
    Observable<ApiResultBean<RegisterBean>> userRegister(@Field("username") String body,
                                                         @Field("password") String ps);


    /********************* 支付模块 ****************************/
    @GET("pay/wxpay")
    Observable<ApiResultBean<WeChatPayConfigBean>> wxPayConfig(@Query("outtradeno") String orderNum);

    /********************* Profile模块 ****************************/
    //积分充值
    @GET("profile/insetIntegralRecharge")
    Observable<ApiResultBean<RechargeInterageBean>> insetIntegralRecharge(@Query("userId") int userId,
                                                                          @Query("money") float money);
    //押金退还
    @GET("profile/applyDeposit")
    Observable<ApiResultBean<UserIdentityBean>> applyDeposit();
    //消息列表
    @GET("profile/getMessages")
    Observable<ApiResultBean<ArrayList<MessageListBean>>> getMessageList(@Query("currentPage") int page,
                                                                         @Query("pageSize") int pageSize);
    //未读消息数
    //实名认证
    @GET("profile/identity/{id}")
    Observable<ApiResultBean<UserIdentityBean>> userIdentity(@Path("id") int userId,
                                                             @Query("idCard") String idCard,
                                                             @Query("realName") String realName);
    //获取用户详细资料
    @GET("profile/myself")
    Observable<ApiResultBean<UserLoginBean>> getUserInfo();
    //赚取积分-建议
    @POST("profile/proposal")
    Observable<ApiResultBean<ProposalBean>> proposal(@Body RequestBody body);
    //赚取积分-发布共享
    @POST("profile/shareGoods")
    Observable<ApiResultBean<ShareGoodsBean>> shareGoods(@Body RequestBody body);
    //预约
    @POST("profile/subscribe")
    Observable<ApiResultBean<AppointmentBean>> userAppointment(@Body RequestBody body);
    //修改用户资料
    @POST("profile/update/{id}")
    Observable<ApiResultBean<UpdateUserInfoBean>> updateUserInfo(@Body RequestBody body, @Path("id") int userId);
    //获取APP信息
    @GET("setting/appConfig")
    Observable<ApiResultBean<AppMsgBean>> getAppConfig();

    /********************* buy模块 ****************************/
    //租用或购买物品
    @GET("buy/createOrder")
    Observable<ApiResultBean<OrderGoodsBean>> createOrder(@Query("shop_id") int shopId,
                                                          @Query("type") int type);


    /********************* 开锁模块 ****************************/
    //扫描解锁，或者是输入编号解锁,返回商品详情
    @GET("device/openDevice")
    Observable<ApiResultBean<GoodsInfoBean>> deviceUniqueNum(@Query("device_unique_num") String body);



    /**********************    供货人供货接口   **********************/
    @GET("supply/checkDevice")//开锁获取商品详情
    Observable<ApiResultBean<GoodsInfoBean>> checkDevice(@Query("device_unique_num") String body);

    @GET("supply/shopInspection")//开贵检查
    Observable<ApiResultBean<GoodsInfoBean>> shopInspection(@Query("shopId") int id,
                                                            @Query("type") int type,
                                                            @Query("reason") String reason);

    @GET("supply/equipmentWarranty")//报修
    Observable<ApiResultBean<GoodsInfoBean>> equipmentWarranty(@Query("device_unique_num") String num,
                                                               @Query("repair") String repair);

    @GET("supply/getSupplyShops")
    Observable<ApiResultBean<ArrayList<DeviceGoodsBean>>> getDeviceShops(@Query("currentPage") int page,
                                                                         @Query("pageSize") int pageSize,
                                                                         @Query("shopName") String name,
                                                                         @Query("device_unique_num") String body);

    @GET("supply/shelvesShop")
    Observable<ApiResultBean<SupplyGoodsBean>> supplyGoods(@Query("shopId") int shpId,
                                                           @Query("deviceSmallId") int sId);
}







